package net.zypro.sample.model;

import net.zypro.sample.C;

/**
 * Created by mac on 15/5/12.
 */
public class ErrorMessage {

    private int code;
    private String message;

    public ErrorMessage(){}

    public ErrorMessage(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ErrorMessage(int code)
    {
        this.code=code;

        switch (code)
        {
            case C.ErrorCode.CLIENT_NET_ERROR:
                this.message="客户端网络异常";
                break;
            case C.ErrorCode.CLIENT_UNKNOWN_ERROR:
                this.message="客户端未知异常";
                break;
            case C.ErrorCode.CLIENT_JSON_ERROR:
                this.message="JSON解析异常";
                break;
            default:
                this.message="";
        }
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return String.format("[code=%d,message=%s]",code,message);
    }
}
